<template>
    <div>
                  <!-- 通过router下标跳转同页面,active默认激活 -->
                  <el-menu
            :default-active="defaultActive"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            unique-opened
            router
          >
            <el-menu-item index="/home">
              <i class="el-icon-menu"></i>
              <span slot="title">首页</span>
            </el-menu-item>

            <el-submenu v-for="item in getuserInfo.menus" :key='item.id' index="1">
              <template slot="title">
                <i :class="item.icon"></i>
                <span>{{item.title}}</span>
              </template>
              
              <el-menu-item v-for="menu in item.children" :key="menu.id" :index="menu.url">{{menu.title}}</el-menu-item>
              <!-- <el-menu-item index="/roler">角色管理</el-menu-item>
              <el-menu-item index="/user">管理员管理</el-menu-item> -->
            </el-submenu>

            <!-- <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-goods"></i>
                <span>商城管理</span>
              </template>
              <el-menu-item index="/goods">商品管理</el-menu-item>
            </el-submenu> -->
          </el-menu>
    </div>
</template>
<script>
import {mapGetters,getMenuList} from 'vuex'
export default {
    data() {
      return {
        defaultActive:'/home',
        // navlink:[]
      }
    },
    computed: {
      ...mapGetters(['getuserInfo']),
      ...mapGetters(['menulist'])
    },
    mounted() {
      // 用户刷新时更改默认选中项,当前地址，类似于滚动加载
      this.defaultActive = this.$route.path
      console.log(this.getuserInfo,'！！');

      
      // console.log(JSON.parse(sessionStorage.getItem('userinfo')),'取出存储的内容');
      // if (sessionStorage.getItem('userinfo')) {
      //   this.navlink = JSON.parse(sessionStorage.getItem('userinfo')).menus
      // }
    },
}
</script>
<style scoped>
.el-menu{
  min-height: 90vh;
}
</style>